﻿using System;
using System.Data;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TaxBiz.User;
using BaseData.UI;

namespace Admin.AjaxPage
{
    public partial class UserInfo : BaseCommon.BasePage
    {
        private const string SelectDataTemplate = "<option value='{0}'>{1}</option>";

        protected void Page_Load(object sender, EventArgs e)
        {
            //if (!HasPower())
            //{
            //    Jscript.AlertAndGoBack("您权限不足，不能操作");
            //    return;
            //}
            string retMessage = string.Empty;
            string action = PageContext.GetRequest("action");

            switch (action.ToLower())
            {
                case "getmanagerlist":
                    string strDepartmentID = PageContext.GetRequest("departmentID");
                    long departmentID = 0;
                    long.TryParse(strDepartmentID, out departmentID);
                    if (departmentID > 0)
                    {
                        retMessage = this.GetManagerList(departmentID);
                    }
                    break;
            }
            Response.ContentType = "text/plain";
            Response.Write(retMessage);
        }

        //获取用户信息
        protected string GetManagerList(long departmentID)
        {
            string managerInfo = string.Empty;
            UserBiz ub = new UserBiz();
            DataTable dt = ub.GetList(departmentID);
            if (dt != null)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    string showName = dr["sName"].ToString();
                    //if (dr["sName"] != DBNull.Value && dr["sName"] != null && dr["sName"].ToString().Length > 0)
                    //{
                    //    showName += "(" + dr["sName"] + ")";
                    //}
                    managerInfo += string.Format(SelectDataTemplate, dr["userid"], showName);
                }
            }
            return managerInfo;
        }
    }
}